package com.carb.controller.member;

import com.carb.dto.ProjectSalesDTO;
import com.carb.result.Result;
import com.carb.service.IProjectService;
import com.carb.vo.ProjectListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 服务项目管理 前端控制器
 * </p>
 *
 * @author XuChaoyang
 * @since 2025-04-06
 */
@RestController("memberProjectController")
@RequestMapping("/member/project")
@Tag(name = "服务项目管理相关接口")
@Slf4j
public class ProjectController {

    @Resource
    private IProjectService projectService;

    /**
     * 查询所有服务项目
     * @return 服务项目信息列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询所有服务项目")
    public Result<List<ProjectListVO>> listProject() {
        log.info("查询所有服务项目");
        List<ProjectListVO> projectListVOList = projectService.listProject();
        log.info("查询所有服务项目成功！");
        return Result.success(projectListVOList);
    }

    /**
     * 查询销量前十服务项目
     * @return 销量前十服务项目列表
     */
    @GetMapping("/top10")
    @Operation(summary = "查询销量前十服务项目")
    public Result<List<ProjectSalesDTO>> getProjectTop10() {
        log.info("查询销量前十服务项目");
        List<ProjectSalesDTO> projectSalesDTOList = projectService.getProjectTop10();
        log.info("查询销量前十服务项目成功！");
        return Result.success(projectSalesDTOList);
    }

}
